package com.codeOfDoom.Sets.SetsCard
{
	import com.codeOfDoom.Sets.Managers.EffectsManager.EffectsManager;
	
	import mx.containers.VBox;
	import mx.controls.Image;

	public class SetsCard extends VBox
	{
		private var _card:Card;
		private var _initizied:Boolean=false;
		private var _selected:Boolean = false;
		//SetsCardImageFactory? 
		//serves as a wrapper class for Card
		//card accessed through composition. do not return _card property.
		public function SetsCard(card:ICard)
		{
			super();
			_card = card as Card;
			height=175;
			setStyle("verticalAlign","middle");
			setStyle("backgroundColor","white");
			//maybe look into handling with events? currently handled with a setter.
			//BindingUtils.bindSetter(setSelectedStyle,this,"selected");
			addImages();
			_initizied=true;
		}
		
		public function set isReplaceCard(replaceCard:Boolean):void{
			_card.isReplaceCard = replaceCard;
		}
		public function get isReplaceCard():Boolean{
			return _card.isReplaceCard;
		}
		public function byName(propertyName:String):String{
			return _card[propertyName];
		}
		
		public function set selected(selected:Boolean):void{
			//turn selected color on or off
			//took out bindingUtil. was running into problems with it not getting called it 
			//it was already true and it was resetting itself.
			if (selected){				
				EffectsManager.addSelectedGlowToCard(this);	    		
 			}
			else{
				EffectsManager.removeSelectedGlowToCard(this);
			}	
		}
		
		public function addImages():void{
			for (var i:int=0;i<_card.number;i++)
			{
				var image:Image = new Image();
				var fileName:String = "../cards/"+_card.getFileNameForCard();
				image.source = fileName;
				this.addChild(image);
			}
		}
		
	}
}